#include "mythread.h"
#include <QDebug>
#include <QMutexLocker>
QMutex myThread::mutex;
int myThread::num = 0;
myThread::myThread(QObject* parent):QThread(parent)
{

}

//void myThread::run()
//{
//    while(1)
//    {
//        this->mutex.lock();
//        qDebug() << "Current Thread" << this << ",Value:" << this->num++;
//        this->mutex.unlock();
//        QThread::sleep(1);
//    }
//}

void myThread::run()
{
    while(1)
    {
        QMutexLocker(&this->mutex);
        qDebug() << "CurrentThread"<<this<<",Value:" << this->num++;
        QThread::sleep(1);
    }
}
